<template>
  <footer class="footer">
    <!-- 统计底部数量条 -->
    <span class="todo-count"
      >剩余：<strong>{{ count }}</strong
      >条数据</span
    >
    <!-- 实现  已完成  未完成  清除已完成的数据 -->
    <ul class="filters" @click="fn">
      <li>
        <a
          :class="{ selected: isSel === 'all' }"
          href="javascript:;"
          @click="isSel = 'all'"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'yes' }"
          href="javascript:;"
          @click="isSel = 'yes'"
          >已完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'no' }"
          href="javascript:;"
          @click="isSel = 'no'"
          >未完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="$emit('clear')">清除已完成</button>
  </footer>
</template>

<script>
export default {
  name: "TodoFooter",
  data() {
    return {
      isSel: "all",
    };
  },
  props: ["arr"],
  methods: {
    fn() {
      this.$emit("getSel", this.isSel);
    },
    // clearFn() {
    //   this.$emit('clear');
    // },
  },
  computed: {
    count() {
      return this.arr.length;
    },
  },
};
</script>